import System
import Numeric

factorial :: Integer -> Integer
{-
    Calculate the nth factorial.

    Use Integer as the type since it is arbitrary precision.
-}
factorial 1 = 1
factorial n = n * factorial (n - 1)

main =
    do
        argv_list <- getArgs
	{- Must typecast 'read' 'to return Integer instead of Int else end up
           with a fixed-precision integer instead of arbitrary precision. -}
        let n = read (head argv_list) :: Integer
        putStr((show (factorial n)) ++ "\n")
